package com.xckj.cycling.context

import android.app.Application
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner

class AppContext : Application() , ViewModelStoreOwner {

    override fun onCreate() {
        _context = this
        super.onCreate()
    }

    companion object {
        private var _context: AppContext? = null

        @JvmStatic
        fun globalContext(): AppContext {
            return _context!!
        }
    }

    var modelStore: ViewModelStore? = null
    override fun getViewModelStore(): ViewModelStore {
        if (modelStore == null) {
            modelStore = ViewModelStore()
        }
        return modelStore!!
    }
}


